<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<link rel="stylesheet" href="/css/font.css">
		<link rel="stylesheet" href="/css/xadmin.css">
		<style>
			form {
				margin-top: 10px;
			}
			
		</style>
	</head>
	<body>
		<form class="layui-form" id="editCourseTimeForm">
			<div class="layui-form-item">
				<label class="layui-form-label"><font color="red" size="3">*</font>上课星期</label>
				<input type="hidden" name="id" th:attr="value=${stuCourse.id}">
				<div class="layui-input-block">
					<select name="startDay" lay-verify="required">
					  <option value=""></option>
                      <option value="1" th:if="${stuCourse.startDay == 1}" selected>1</option>
                      <option value="1" th:if="${stuCourse.startDay != 1}">1</option>
                      <option value="2" th:if="${stuCourse.startDay == 2}" selected>2</option>
                      <option value="2" th:if="${stuCourse.startDay != 2}">2</option>
                      <option value="3" th:if="${stuCourse.startDay == 3}" selected>3</option>
                      <option value="3" th:if="${stuCourse.startDay != 3}">3</option>
                      <option value="4" th:if="${stuCourse.startDay == 4}" selected>4</option>
                      <option value="4" th:if="${stuCourse.startDay != 4}">4</option>
                      <option value="5" th:if="${stuCourse.startDay == 5}" selected>5</option>
                      <option value="5" th:if="${stuCourse.startDay != 5}">5</option>
					</select>
				</div>
			</div>
			<div class="layui-form-item">
                <label class="layui-form-label"><font color="red" size="3">*</font>上课时间</label>
                <div class="layui-input-block">
                    <select name="startTime" lay-verify="required">
                      <option value=""></option>
                      <option value="12" th:if="${ stuCourse.startTime == 12 }" selected>12</option>
                      <option value="12" th:if="${ stuCourse.startTime != 12 }">12</option>
                      <option value="34" th:if="${ stuCourse.startTime == 34 }" selected>34</option>
                      <option value="34" th:if="${ stuCourse.startTime != 34 }">34</option>
                      <option value="56" th:if="${ stuCourse.startTime == 56 }" selected>56</option>
                      <option value="56" th:if="${ stuCourse.startTime != 56 }">56</option>
                      <option value="78" th:if="${ stuCourse.startTime == 78 }" selected>78</option>
                      <option value="78" th:if="${ stuCourse.startTime != 78 }">78</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><font color="red" size="3">*</font>授课教室</label>
                <div class="layui-input-block">
                    <input type="text" name="roomName" th:attr="value=${stuCourse.roomName}" required lay-verify="required|roomName" placeholder="教学楼-教室号" autocomplete="off" class="layui-input">
                </div>
            </div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn" lay-submit lay-filter="formDemo" type="button">立即提交</button>
				</div>
			</div>
		</form>
		
		<script type="text/javascript" src="/js/jquery.min.js"></script>
        <script type="text/javascript" src="/js/xadmin.js"></script>
        <script type="text/javascript" src="/lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="/js/vue.min.js"></script>
        <script type="text/javascript" src="/js/jquery.form.js"></script>
		<script>
			layui.use(['form', 'layedit', 'laydate'], function(){
				var form = layui.form
				,layer = layui.layer
				
				form.verify({
					roomName:[/[\S]+\-[\S]+$/,'教学楼-教室号，中间‘-’做分隔']
				});
			
				//监听提交
				form.on('submit(formDemo)', function(data){
					$.ajax({
                        url : "/sys/student/course/updateStuCourse",
                        type : "post",
                        data : $("#editCourseTimeForm").serializeArray(),
                        success : function(result) {
                            if (result.state) {
                                layer.msg('修改成功！', {icon: 1,time: 1000}, function(){
                                    // 1.先得到当前iframe层的索引
                                    var index = parent.layer.getFrameIndex(window.name); 
                                    // 2.再执行关闭 
                                    parent.layer.close(index); 
                                    // 调用父页面的方法
                                    window.parent.updateEditData();
                                });
                            } else {
                                layer.msg(""+result.msg, {icon: 5});
                            }
                        }
                    });
				});
			});
		</script>
	</body>
</html>
